Skip to content

feat(frontend): show estimated end date/time preview in CreateStreamF…#185

Merged
ritik4ever merged 2 commits into
ritik4ever:mainfrom
Danielodingz:wave4/163-estimated-end-date-preview
Apr 28, 2026
Merged

feat(frontend): show estimated end date/time preview in CreateStreamF…#185
ritik4ever merged 2 commits into
ritik4ever:mainfrom
Danielodingz:wave4/163-estimated-end-date-preview

Conversation

@Danielodingz
Copy link
Copy Markdown
Contributor

@Danielodingz Danielodingz commented Apr 25, 2026

Closes #163

[wave4][frontend] Show estimated end date/time preview in CreateStreamForm

Summary

As the user fills in the Duration (hours) and Start In (minutes) fields, the form now computes and displays a real-time estimated end date/time preview directly below the duration input.

Changes

File: frontend/src/components/CreateStreamForm.tsx

  • Added the missing durationHours input field (existed in state and validation but was not rendered in the JSX).
  • Added an estimatedEndLabel computed value (inline IIFE, no hooks) that derives the estimated end timestamp from startAt + durationSeconds.
  • Rendered the preview as a <span className="field-hint"> with aria-live="polite" below the duration input — clears automatically when either field is empty or invalid.

Acceptance Criteria

  • Derived from startAt + durationSeconds in real time
  • Format: Ends: Apr 30, 2026 at 14:32 UTC
  • Updates on every keystroke without debounce
  • Clears when either field is empty/invalid
  • Uses Intl.DateTimeFormat — no external date library

Notes

  • No new dependencies introduced.
  • No existing logic, formatting, or unrelated code modified.
  • startAt derivation mirrors the existing logic in handleSubmit exactly.

Summary by CodeRabbit

  • New Features

    • Added dynamic UTC end-time estimate display that updates based on duration and start time inputs.
    • Improved form controls with clearer, separate fields for duration (hours) and start timing (minutes).
  • Improvements

    • Enhanced input validation with better error messaging and accessibility wiring.
    • Strengthened numeric input handling with client-side restrictions.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

@Danielodingz is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 25, 2026

@Danielodingz Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Danielodingz
Copy link
Copy Markdown
Contributor Author

Hey @ritik4ever please check PR and merge, Thanks

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

A single React form component is updated to calculate and display a dynamic UTC end-time estimate based on user-provided start offset and duration values. New dedicated form controls are introduced for "Duration (hours)" and "Start In (minutes)" with validation constraints, accessibility wiring, and numeric input restrictions.

Changes

Cohort / File(s) Summary
Form End-Time Estimation
frontend/src/components/CreateStreamForm.tsx
Adds dynamic end-time label calculation (estimatedEndLabel) that derives UTC end-time from start offset and duration inputs. Introduces new form controls for duration and start time with min/step constraints, accessibility attributes (aria-describedby, aria-invalid), and client-side keyboard event prevention to restrict non-numeric characters. Updates form validation and rendering logic accordingly.

Sequence Diagram

sequenceDiagram
    participant User
    participant Form as Form Component
    participant Calculator as Date Calculator
    participant Display as UI Display

    User->>Form: Enters start offset (minutes)
    Form->>Form: Validates input
    
    User->>Form: Enters duration (hours)
    Form->>Form: Validates input & checks both present
    
    Form->>Calculator: Passes startAt + durationSeconds
    Calculator->>Calculator: Calculate end date/time
    Calculator->>Calculator: Format with Intl.DateTimeFormat
    Calculator-->>Form: Returns estimatedEndLabel
    
    Form->>Display: Renders "Ends: [UTC date/time]"
    Display-->>User: Shows estimated end time preview
    
    Note over User,Display: Updates on every keystroke<br/>Clears if either field becomes empty/invalid
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 As you hop through forms with care,
Time's end shows without a spare,
UTC calculates with grace,
Real-time previews fill the space!
Form controls now shine so bright,

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main feature: adding an estimated end date/time preview to CreateStreamForm, matching the primary change in the changeset.
Linked Issues check ✅ Passed All acceptance criteria from issue #163 are met: real-time computation from startAt+durationSeconds, correct UTC format, keystroke updates, clearing on empty/invalid fields, and Intl.DateTimeFormat usage.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the estimated end date/time preview feature. Form control improvements (min/step constraints, aria attributes, numeric key prevention) are necessary supporting changes within scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Danielodingz
Copy link
Copy Markdown
Contributor Author

Hey @ritik4ever please conflict has been resolved, please merge thanks.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/components/CreateStreamForm.tsx`:
- Around line 409-412: The JSX conditional for errors.startInMinutes in
CreateStreamForm is left unclosed and the old "Duration & Start In Minutes"
block remains, causing unbalanced JSX and duplicate IDs (stream-duration /
stream-start); close the conditional branch properly (close the span and the
surrounding conditional block that started with {errors.startInMinutes && ( ...
)}) where the error span is rendered, and remove the stale duplicate "Duration &
Start In Minutes" row (the duplicate DOM containing ids stream-duration and
stream-start) so only the new, balanced start/duration fields remain.
- Around line 171-172: The form contract in useFormValidation is still only
defining durationMinutes so values.durationHours, errors.durationHours and
set("durationHours") in CreateStreamForm are left undefined/unvalidated and
handleSubmit still posts values.durationMinutes; update the validation/form
state to include durationHours (add durationHours to the values/defaults,
validate it like durationMinutes but in hours and ensure errors.durationHours is
set), change handleSubmit to use the canonical field (either compute
durationMinutes = durationHours * 60 or post durationHours consistently), and
update any preview/end-time computation to read from values.durationHours so the
submitted payload and preview match (look for references to durationMinutes,
values.durationHours, errors.durationHours, set("durationHours"), and
handleSubmit).
- Around line 174-181: The current validation in CreateStreamForm clears preview
only for invalid durationHours; extend that guard to also treat startInMinutes
as invalid when it's negative or non-integer so estimatedEndLabel is cleared in
those cases. Update the if condition that checks values.startInMinutes,
startInMinsNum, durationHoursNum (the block that decides whether to render
estimatedEndLabel) to include startInMinsNum < 0 ||
!Number.isInteger(startInMinsNum) (in addition to the existing empty/isNaN
checks) so pasting "-5" or "1.5" into startInMinutes causes the preview to be
cleared.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3ede09e1-b1f9-4222-9737-56d88998b43d

📥 Commits

Reviewing files that changed from the base of the PR and between 0b3c74c and b7040cf.

📒 Files selected for processing (1)
  • frontend/src/components/CreateStreamForm.tsx

Comment thread frontend/src/components/CreateStreamForm.tsx
Comment on lines +174 to +181
if (
values.startInMinutes === "" ||
values.durationHours === "" ||
isNaN(startInMinsNum) ||
isNaN(durationHoursNum) ||
durationHoursNum < 1 ||
!Number.isInteger(durationHoursNum)
) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Clear the preview when startInMinutes is invalid too.

This guard only rejects invalid durationHours. If a user pastes -5 or 1.5 into Line 394, estimatedEndLabel still renders instead of clearing, which misses the “clear when either field is empty or invalid” requirement.

Suggested fix
     if (
       values.startInMinutes === "" ||
       values.durationHours === "" ||
       isNaN(startInMinsNum) ||
       isNaN(durationHoursNum) ||
+      startInMinsNum < 0 ||
+      !Number.isInteger(startInMinsNum) ||
       durationHoursNum < 1 ||
       !Number.isInteger(durationHoursNum)
     ) {
       return null;
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/components/CreateStreamForm.tsx` around lines 174 - 181, The
current validation in CreateStreamForm clears preview only for invalid
durationHours; extend that guard to also treat startInMinutes as invalid when
it's negative or non-integer so estimatedEndLabel is cleared in those cases.
Update the if condition that checks values.startInMinutes, startInMinsNum,
durationHoursNum (the block that decides whether to render estimatedEndLabel) to
include startInMinsNum < 0 || !Number.isInteger(startInMinsNum) (in addition to
the existing empty/isNaN checks) so pasting "-5" or "1.5" into startInMinutes
causes the preview to be cleared.

Comment thread frontend/src/components/CreateStreamForm.tsx
@ritik4ever ritik4ever merged commit f9f7656 into ritik4ever:main Apr 28, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wave4][frontend] Show estimated end date/time preview as user fills form

2 participants